<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<html>
<head>
    <title></title>
    <link href="<c:url value="/resources/css/social-buttons-3.css" />"
	rel="stylesheet" type="text/css" />
	<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="page-header">
    <h1><spring:message code="label.user.login.page.title" text="default title"/></h1>
</div>
<!--
    If the user is anonymous (not logged in), show the login form
    and social sign in buttons.
-->
<sec:authorize access="isAnonymous()"><!-- Returns true if the current principal is an anonymous user -->
    <!-- Login form -->
    <div class="panel panel-default">
        <div class="panel-body">
            <h2><spring:message code="label.login.form.title" text="defualt title"/></h2>
            <!--
                Error message is shown if login fails.
            -->
            <c:if test="${param.error eq 'bad_credentials'}">
                <div class="alert alert-danger alert-dismissable">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <spring:message code="text.login.page.login.failed.error" text="default message if given code isn't provided"/>
                </div>
            </c:if>
            <!-- Login-Form : Specifies action and HTTP method -->
            <form method="post" action="<c:url value='j_spring_security_check'/>" role="form">
<%--             <form action="<c:url value='j_spring_security_check'/>" method="POST" role="form"> --%>
                <!-- Add CSRF token to request-->
                <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
                <div class="row">
                    <div id="form-group-email" class="form-group col-lg-4">
                        <label class="control-label" for="user-email"><spring:message code="label.user.email" text="defaul email"/>:</label>
                        <!-- Add username field to the login form -->
<!--                         id="user-email" -->
                         <input id="j_username" name="j_username" type="text" class="form-control"/>  
                    </div>
                </div>
 
                <div class="row">
                    <div id="form-group-password" class="form-group col-lg-4">
                        <label class="control-label" for="user-password"><spring:message code="label.user.password" text="defualt password"/>:</label>
                        <!-- Add password field to the login form -->
<!--                         id="user-password" -->
                        <input id="j_password" name="j_password" type="password" class="form-control"/>
                    </div>
                </div>
                <div class="row">
                    <div class="form-group col-lg-4">
                        <!-- Add submit button -->
                        <button type="submit" class="btn btn-default"><spring:message code="label.user.login.submit.button" text="default submit"/></button>
                    </div>
                </div>
            </form>
<!--             Create user account’ link below the login form. This link creates a GET request to url ‘/user/register’ -->
            <div class="row">
                <div class="form-group col-lg-4">
                    <!-- Add create user account link -->
                    <a href="${pageContext.request.contextPath}/user/register"><spring:message code="label.navigation.registration.link" text="default registion link"/></a>
                </div>
            </div>
        </div>
    </div>
    <!-- Social Sign In Buttons -->
    <div class="panel panel-default">
        <div class="panel-body">
            <h2><spring:message code="label.social.sign.in.title" text="default title"/></h2>
<!--             Add Facebook sign in button. This button must create a GET request to url ‘/auth/facebook’. -->
            <div class="row social-button-row">
                <div class="col-lg-4">
                    <!-- Add Facebook sign in button -->
                    <a href="${pageContext.request.contextPath}/auth/facebook"><button class="btn btn-facebook"><i class="icon-facebook"></i> | <spring:message code="label.facebook.sign.in.button" text="default facebook"/></button></a>
                </div>
            </div>
<!--             Add Twitter sign in button. This button must create a GET request to url ‘/auth/twitter’. -->
            <div class="row social-button-row">
                <div class="col-lg-4">
                    <!-- Add Twitter sign in Button -->
                    <a href="${pageContext.request.contextPath}/auth/twitter"><button class="btn btn-twitter"><i class="icon-twitter"></i> | <spring:message code="label.twitter.sign.in.button" text="default twitter"/></button></a>
                </div>
            </div>
        </div>
    </div>
</sec:authorize>
<!--
    If the user is already authenticated, show a help message instead
    of the login form and social sign in buttons.
-->
<!-- Returns true if the user is not anonymous -->
<sec:authorize access="isAuthenticated()">
    <p><spring:message code="text.login.page.authenticated.user.help" text="default help"/></p>
</sec:authorize>
</body>
</html>